*** Settings ***
Documentation  包含数据库新增、编辑、检索、删除。未包含数据库详情页字段验证。
Resource  ../流程层.robot
Suite Setup  登录
Suite Teardown  关闭浏览器
Force Tags  回归测试

*** Variables ***
#&{sqlConf}  sqlName=sqlserver  sqlDoc=sqlserver数据库  sqlType=1  serverIp=172.28.28.170  sqlPort=1433  sqlDb=dhcc13
#...  sqlUser=dhcc13  sqlPwd=dhcc130424
#&{sqlConf}  sqlName=mysql  sqlDoc=mysql数据库  sqlType=2  serverIp=172.28.28.169  sqlPort=3306  sqlDb=dhcc12
#...  sqlUser=dhcc12  sqlPwd=dhcc120924
#&{sqlConf}  sqlName=db2  sqlDoc=db2数据库  sqlType=3  serverIp=172.28.28.171  sqlPort=50000  sqlDb=dhcc10
#...  sqlUser=dhcc13  sqlPwd=dhcc100424
&{sqlConf}  sqlName=oracle  sqlDoc=oracle数据库  sqlType=4  serverIp=172.28.28.168  sqlPort=1521  sqlDb=orcl
...  sqlUser=dhcc27  sqlPwd=dhcc270716
*** Test Cases ***
数据库创建正例
    [Tags]  关键测试
    进入数据库管理页
    # 点击创建按钮
    点击元素  xpath=/html[1]/body[1]/div[1]/div[1]/div[2]/div[1]/div[1]/ul[1]/li[1]/button[1]/span[1]
    # 输入基本信息
    输入文本  xpath=//*[@id="app"]/div/div/div[2]/div/div/form/div[1]/div[1]/div[1]/div/div/span/div/input
    ...  ${sqlConf}[sqlName]
    输入文本  xpath=//*[@id="app"]/div/div/div[2]/div/div/form/div[1]/div[1]/div[2]/div/div/span/div/input
    ...  ${sqlConf}[sqlDoc]
    # 点击数据库类型
    点击元素  xpath=//input[@placeholder='请选择']
    sleep  1
    # 数据库类型选择 1=sqlserver类型 2=mysql类型 3=db2类型 4=oracle类型
    run keyword if  '${sqlConf}[sqlType]'=='1'  点击元素  xpath=/html/body/div[2]/div[1]/div[1]/ul/li[1]
    ...  ELSE IF  '${sqlConf}[sqlType]'=='2'  点击元素  xpath=/html/body/div[2]/div[1]/div[1]/ul/li[2]
    ...  ELSE IF  '${sqlConf}[sqlType]'=='3'  点击元素  xpath=/html/body/div[2]/div[1]/div[1]/ul/li[3]
    ...  ELSE  点击元素  xpath=/html/body/div[2]/div[1]/div[1]/ul/li[4]
    输入文本  xpath=//*[@id="app"]/div/div/div[2]/div/div/form/div[1]/div[2]/div[2]/div/div/span/div/input
    ...  ${sqlConf}[serverIp]
    输入文本  xpath=//*[@id="app"]/div/div/div[2]/div/div/form/div[1]/div[3]/div[1]/div/div/span/div/input
    ...  ${sqlConf}[sqlPort]
    输入文本  xpath=//*[@id="app"]/div/div/div[2]/div/div/form/div[1]/div[3]/div[2]/div/div/span/div/input
    ...  ${sqlConf}[sqlDb]
    输入文本  xpath=//*[@id="app"]/div/div/div[2]/div/div/form/div[1]/div[4]/div[1]/div/div/span/div/input
    ...  ${sqlConf}[sqlUser]
    输入文本  xpath=//*[@id="app"]/div/div/div[2]/div/div/form/div[1]/div[4]/div[2]/div/div/div[1]/input
    ...  ${sqlConf}[sqlPwd]
    # 测试链接按钮功能测试
    点击元素  xpath=//*[@id="app"]/div/div/div[2]/div/div/form/div[1]/div[2]/p/button
    ${connectMess}  获取文本  xpath=/html/body/div[3]/div/div[2]/div[1]/div[2]/p/p[2]
    should be equal  ${connectMess}  数据库连接成功！
    # 点击确定按钮
    点击元素  xpath=/html/body/div[3]/div/div[3]/button
    # 点击提交按钮
    点击元素  xpath=//*[@id="app"]/div/div/div[2]/div/div/form/div[2]/div/div/div/div/button[1]
    sleep  0.5
    # 获取提示信息文本并断言
    ${messeage}  获取文本  xpath=//p[@class='box_message']
    should be equal  ${messeage}  处理成功
    # 点击确认按钮
    点击元素  xpath=/html/body/div[3]/div/div[3]/button

数据库检索
    [Tags]  关键测试
    unselect frame
    进入数据库管理页
    # 输入筛选条件
    输入文本  xpath=//*[@id="app"]/div/div[1]/div/div[2]/div/form/div[1]/div[1]/div[1]/div/div/span/div/input
    ...  ${sqlConf}[sqlName]
    输入文本  xpath=//*[@id="app"]/div/div[1]/div/div[2]/div/form/div[1]/div[1]/div[2]/div/div/span/div/input
    ...  ${sqlConf}[sqlDoc]
    点击元素  xpath=//*[@id="app"]/div/div[1]/div/div[2]/div/form/div[1]/div[1]/div[3]/div/div/div/div/div/input
    sleep  0.5
    run keyword if  '${sqlConf}[sqlType]'=='1'  点击元素  xpath=/html/body/div[3]/div[1]/div[1]/ul/li[1]
    ...  ELSE IF  '${sqlConf}[sqlType]'=='2'  点击元素  xpath=/html/body/div[3]/div[1]/div[1]/ul/li[2]
    ...  ELSE IF  '${sqlConf}[sqlType]'=='3'  点击元素  xpath=/html/body/div[3]/div[1]/div[1]/ul/li[3]
    ...  ELSE  点击元素  xpath=/html/body/div[3]/div[1]/div[1]/ul/li[4]
    # 点击检索按钮
    点击元素  xpath=//*[@id="app"]/div/div[1]/div/div[2]/span/button[1]
    ${t1}  获取文本
    ...  xpath=//*[@id="app"]/div/div[2]/div[2]/div/div/div/div[1]/div[3]/table/tbody/tr/td[1]/div/div/span/span
    should be equal  ${t1}  ${sqlConf}[sqlName]

数据库编辑
    [Tags]  关键测试
    unselect frame
    进入数据库管理页
    # 输入数据库名称
    输入文本  xpath=//*[@id="app"]/div/div[1]/div/div[2]/div/form/div[1]/div[1]/div[1]/div/div/span/div/input
    ...  ${sqlConf}[sqlName]
    # 点击检索按钮
    点击元素  xpath=//*[@id="app"]/div/div[1]/div/div[2]/span/button[1]
    # 点击编辑按钮
    点击元素
    ...  xpath=//*[@id="app"]/div/div[2]/div[2]/div/div/div/div[1]/div[3]/table/tbody/tr/td[7]/div/div/span/button[1]
    # 修改数据库描述
    输入文本  xpath=//*[@id="app"]/div/div/div[2]/div/div/form/div[1]/div[1]/div[2]/div/div/span/div/input
    ...  修改后的描述
    # 点击提交按钮
    点击元素  xpath=//*[@id="app"]/div/div/div[2]/div/div/form/div[2]/div/div/div/div/button[1]
    sleep  0.5
    # 获取提示信息文本并断言
    ${messeage1}  获取文本  xpath=//p[@class='box_message']
    should be equal  ${messeage1}  处理成功
    # 点击确认按钮
    点击元素  xpath=/html/body/div[3]/div/div[3]/button

检索界面清空按钮功能测试
    unselect frame
    进入数据库管理页
    # 输入筛选条件
    输入文本  xpath=//*[@id="app"]/div/div[1]/div/div[2]/div/form/div[1]/div[1]/div[1]/div/div/span/div/input
    ...  ${sqlConf}[sqlName]
    输入文本  xpath=//*[@id="app"]/div/div[1]/div/div[2]/div/form/div[1]/div[1]/div[2]/div/div/span/div/input
    ...  ${sqlConf}[sqlDoc]
    点击元素  xpath=//*[@id="app"]/div/div[1]/div/div[2]/div/form/div[1]/div[1]/div[3]/div/div/div/div/div/input
    sleep  0.5
    run keyword if  '${sqlConf}[sqlType]'=='1'  点击元素  xpath=/html/body/div[3]/div[1]/div[1]/ul/li[1]
    ...  ELSE IF  '${sqlConf}[sqlType]'=='2'  点击元素  xpath=/html/body/div[3]/div[1]/div[1]/ul/li[2]
    ...  ELSE IF  '${sqlConf}[sqlType]'=='3'  点击元素  xpath=/html/body/div[3]/div[1]/div[1]/ul/li[3]
    ...  ELSE  点击元素  xpath=/html/body/div[3]/div[1]/div[1]/ul/li[4]
    # 点击清空按钮
    点击元素  xpath=//*[@id="app"]/div/div[1]/div/div[2]/span/button[2]
    ${emptyText}  获取值
    ...  xpath=//*[@id="app"]/div/div[1]/div/div[2]/div/form/div[1]/div[1]/div[1]/div/div/span/div/input
    should be empty  ${emptyText}
    ${emptyText1}  获取值
    ...  xpath=//*[@id="app"]/div/div[1]/div/div[2]/div/form/div[1]/div[1]/div[2]/div/div/span/div/input
    should be empty  ${emptyText1}
    ${typeText}  获取值
    ...  xpath=//*[@id="app"]/div/div[1]/div/div[2]/div/form/div[1]/div[1]/div[3]/div/div/div/div/div/input
    should be empty  ${typeText}

删除数据库
    [Tags]  关键测试
    unselect frame
    进入数据库管理页
    # 输入数据库名称
    输入文本  xpath=//*[@id="app"]/div/div[1]/div/div[2]/div/form/div[1]/div[1]/div[1]/div/div/span/div/input
    ...  ${sqlConf}[sqlName]
    # 点击检索按钮
    点击元素  xpath=//*[@id="app"]/div/div[1]/div/div[2]/span/button[1]
    # 点击删除按钮
    点击元素
    ...  xpath=//*[@id="app"]/div/div[2]/div[2]/div/div/div/div[1]/div[3]/table/tbody/tr/td[7]/div/div/span/button[2]
    # 点击确定
    点击元素  xpath=/html/body/div[3]/div/div[3]/button[2]
    # 获取提示信息文本并断言
    ${messeage2}  获取文本  xpath=/html/body/div[3]/div/div[2]/div[1]/div[2]/p/p[2]
    should be equal  ${messeage2}  处理成功
    # 点击确认按钮
    点击元素  xpath=/html/body/div[3]/div/div[3]/button
